#!/bin/bash
ping -c 1 www.baidu.com > /dev/null 2>&1
if [ $? = 0 ]
then
    true
else
    PIDs=$(ps -aux | grep "wpa_supplicant" | grep -v "grep" | gawk -F' {2,}' '{print $2}')
    kill $PIDs
    /usr/local/bin/wificonnect.sh
    echo "Wifi reconnected!"
fi 

